<template>
    <div>
        <div class="section">
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    <div v-for="s in slides" class="swiper-slide">
                        <img :src="s.img_url"/>
                    </div>
                </div>
                <div class="swiper-pagination"></div>
            </div>
            <div class="announcement">
                <label>快讯</label>
                <span>{{announcement}}</span>
            </div>
        </div>

    </div>
</template>

<script type="text/ecmascript-6">
    import Swiper from "swiper"
    import 'swiper/dist/css/swiper.css'


    export default {
//        data() {
//            return {
//                announcement: '今日上架的图书全部8折',
//                slides: [{img_url: require('./fixtures/sliders/t1.svg')}
//                    , {img_url: require('./fixtures/sliders/t2.svg')}]
//            }
//        }
        props:['announcement','slides'],
beforeMount(){
  console.log("slider beforeMount");
},
        beforeCreate(){
            console.log("slider beforeCreate");
        },
        create(){
            console.log("slider created");
        },
         mounted() {
             window.setTimeout(function()
             {
                 console.log("slider setTimeout");
                 new Swiper('.swiper-container', {
                     pagination: '.swiper-pagination',//this.$refs.pagination,
                     paginationClickable: true,
                     spaceBetween: 30,
                     centeredSlides: true,
                     autoplay: 2500,
                     autoplayDisableOnInteraction: false
                 })
             },1000);
             console.log("slider mounted");
         }
    }
</script>